<template>
      <nav>
<div id="header">
        <img src="@/assets/images/2.png" alt=""> <p>我的订单</p>
    </div><hr>
 </nav>
    <div id="back" @click="$router.go(-1)">
            <img src="@/assets/images/back.png" alt=""><i></i>
        </div>
    <div class="shop-cart">
        <div class="lists">
            <div class="header">
                <ul class="clearfix">
                    <li></li>
                    <li class="product-info">商品信息</li>
                    <li>收货地址</li>
                    <li>数量</li>
                    <li>金额</li>
                    <li>状态</li>
                </ul>
            </div>
            <div id="shoplist" class="shoplist"  v-for="p in products" :key="p.productId">
                 <div class="shop" v-show="active">
                      <div class="shop-info">
                        <span class="shop-tip"><img src="@/assets/images/shop2.png" > 店铺：</span>
                        <a class="shop-name" href="#">{{p.shopName}}</a></div>
                    <div class="products align-items-center" >
                        <div class="item">
                            <div class="select-logo">
                                <span ><img :src="p.imgs" alt=""></span>
                            </div>
                            <div class="product-detail">
                                <div class="right">
                                     <p>名称：{{p.name}}</p>
                                    <p>水果价格：{{p.realprice}}元/kg</p>
                                    <p>来源地：{{p.productDress}}</p>
                                    <p>月销量：{{p.mcount}}kg</p>
                                    <p>售后说明：{{p.production}}</p>
                                </div>
                            </div>
                            <div class="price align-items-center">
                                <p class="real-price" style="font-size:12px;">17783534732</p>
                                <p style="font-size:16px;">重庆市重庆工程学院南泉校区</p>
                            </div>
                            <div class="count">
                                <p>{{p.count}}kg</p>
                            </div>
                            <div class="amount">￥{{p.pay}}元</div>
                            <div class="delete">
                                <a href="#"><i style="font-size:18px;color:#11f446">{{p.status}}</i></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="operate">
            <div class="left">
                <a href="javascript:void(0);"  @click="delAll()">清空</a>
            </div>
            <div class="right">
                <a href="javascript:void(0);" class="settle" @click="donePay" >已支付订单</a>
                <a href="javascript:void(0);" class="settle" @click="withoutPay">未支付订单</a>
                <a href="javascript:void(0);" class="settle1" >全部订单</a>
            </div>
        </div>
    </div>
</template>

<script>
import { reqOrder } from '@/api/allMsg'
import { ref, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
export default {
  name: 'orderView',
  setup () {
    const products = ref('')
    onMounted(async () => {
      const res = await reqOrder()
      products.value = res.data.data
    })

    // 清空
    function delAll () {
      ElMessageBox.confirm(
        '确认清空购物车?',
        'Warning',
        {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
        products.value = ''
        ElMessage({
          type: 'success',
          message: '清空成功！'
        })
      }).catch(() => {
        ElMessage({
          type: 'info',
          message: '清空失败！'
        })
      })
    }

    const active = ref(true)
    function donePay () {
      active.value = true
    //   products.value.forEach((item) => {
    //     if (item.status === '已支付') {
    //       active.value = true
    //     }
    //   })
    }
    function withoutPay () {
      active.value = false
    }
    return {
      products, delAll, donePay, withoutPay, active
    }
  }
}
</script>

<style scoped>
nav{
    background-color:black;
}
#header>img{
    margin: 10px;
}
#back>img{
    width:40px;height: 40px;
    position:absolute;
    margin-top: 10px;
    margin-left: 20px;
    cursor: pointer;
}
 #header>p{
    font-size: 35px;
    font-weight: bolder;
    color: #b0b436;
    position: absolute;
    margin-left: 100px;
    margin-top: -60px;
    }
hr{
    height: 4px;
    background-color:#b0b436;
    /* margin-top: 50px; */
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
ul {
    list-style: none;
}
.shop-cart {
    width: 990px;
    margin: 10px auto;
    /* border: 1px solid red; */
    /* background-color:rgb(199, 202, 40, 0.5); */
    user-select: none;
}
.lists .header ul {
    font-weight: bolder;
    height: 50px;
    line-height: 50px;
    color:#6e710b;
    margin-left: 120px;
}

.lists .header ul li {
    float: left;
}

.lists .header ul li:not(.product-info) {
    width: 125px;
    /* margin-right: 30px; */
}

.lists .header ul li.product-info {
    width: calc(990px - (125px * 5));
}

.lists .shop .products {
    border: 1px solid #ccc;
    margin: 10px;
}

.lists .shop .products .item {
    display: flex;
    padding: 20px 10px;
    border-bottom: 1px solid #eee;
}

.lists .shop .products .item .select-logo {
    display: flex;
}

.lists .shop .products .item .select-logo img {
    width: 100px;
    height: 90px;
    margin-left: 8px;
}

.lists .shop .products .item .product-detail {
    width: calc(990px - (125px * 5));
    display: flex;
    margin-left: 18px;
}
.lists .shop .products .item>div:not(.product-detail) {
    width: 128px;
}

.lists .shop .products .item .price p {
    margin: 4px 0;
    margin-left: -20px;
    margin-top: 10px;
}

.lists .shop .products .item .price p.market-price {
    color: #9c9c9c;
    text-decoration: line-through;
}
.lists .shop .products .item .count span.sub, .lists .shop .products .item .count span.add {
    background-color: #f0f0f0;
    color: #b0b436;
    width: 17px;
    border: 1px solid #e5e5e5;
}

.lists .shop .products .item .count span.sub:hover, .lists .shop .products .item .count span.add:hover {
    color: #ff4400;
    border-color: #ff4400;
}

.lists .shop .products .item .count span.input {
    border: 1px solid #aaa;
}

.lists .shop .products .item .count span.input input {
    width: 40px;
    height: 21px;
    text-align: center;
    border: none;
}

.lists .shop .products .item .amount {
    color: #ff4400;
    font-weight: bold;
    font-size: 14px;
    margin-top: 40px;
}
.lists .shop .products .item .count,.delete {
    margin-top: 40px;
}

.lists .shop .products .item .delete a {
    color: #3c3c3c;
    text-decoration: none;
}

.operate {
    height: 50px;
    background-color:#f2f3d5;
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #b0b436;
    position: sticky;
    bottom: 0;
    left: 0;
}

.operate .left {
    padding-left: 10px;
}

.operate .left a {
    text-decoration: none;
    color: #797c27;
    margin-left: 30px;
}

.operate .left a:hover {
    text-decoration: underline;
    color: #ff4400;
}

.operate .right {
    display: flex;
    justify-content: end;
    align-items: center;
    font-weight: bolder;
    cursor: pointer;
}

.operate .right .amount {
    margin-left: 40px;
}

.operate .right .selected-count, .operate .right .sum {
    color: #ff4400;
    font-size: 18px;
    font-weight: 600;
    margin: 0 5px;
}
.operate .right a {
    height: 50px;
    line-height: 50px;
    width: 120px;
    /* background-color: #b0b436; */
    text-align: center;
    text-decoration: none;
    color: #b0b436;
    font-size: 20px;
}

.operate .right a:hover {
    height: 50px;
    line-height: 50px;
    width: 120px;
    background-color: #b0b436;
    text-align: center;
    text-decoration: none;
    color: #fff;
    font-size: 20px;
}
.operate .right .settle1{
    height: 50px;
    line-height: 50px;
    width: 120px;
    background-color: #b0b436;
    text-align: center;
    text-decoration: none;
    color: #fff;
    font-size: 20px;
}

.operate .right a.active {
    background-color: #ff4400;
}

.operate .right a.active:hover {
    background-color: #f22d00;
}
.active1{background-color: rgb(236, 213, 217);}
input{
    width: 18px;height: 18px;
}
.shop-name{
    text-decoration: none;
    color:#30302e;
    font-weight: bolder;
}
.shop-info{
    margin-top: 20px;
    margin-left: 45px;
}
.right>p{
    margin-bottom: 8px;
    color: rgb(78, 76, 76);
    font-size: 14px;
}
.shop-tip>img{
    width: 30px;height: 30px;
    position: absolute;
    margin-left: -35px;
    margin-top: -5px;
}
.count>P{
    margin-left: 20px;
}
</style>
